package org.lep.leetcode.datastructure.stack.queueusingstack;

import java.util.Deque;
import java.util.LinkedList;

/**
 * https://leetcode.com/problems/implement-stack-using-queues
 *
 * @author lverpeng
 * @since 2020/3/10
 */
public class MyStack {
    private Deque<Integer> deque = null;
    /** Initialize your data structure here. */
    MyStack() {
        deque = new LinkedList<>();
    }

    /** Push element x onto stack. */
    void push(int x) {
        deque.push(x);
    }

    /** Removes the element on top of the stack and returns that element. */
    int pop() {
        return deque.pollFirst();
    }

    /** Get the top element. */
    int top() {
        return deque.getFirst();
    }

    /** Returns whether the stack is empty. */
    boolean empty() {
        return deque.isEmpty();
    }
}
